/**
 * Created by gongxun on 17/2/24.
 */

var PszTableRoomEndPlayerWidget = GameBaseItem.extend({
    mSeat : null,
    //0:纵向 1:横向
    mType : null,
    mPlayerNode : null,
    ctor : function (seat, type) {
        this._super();
        this.loadCocostudio("res/ccs/PszTableRoomEndPlayer.json");
        mo.gameHelper.fixIosText(this.ccsNode);

        this.mSeat = seat;
        this.mType = type;

        var Panel_ver = mo.seekWidgetByName(this.ccsNode, "Panel_ver");
        var Panel_hor = mo.seekWidgetByName(this.ccsNode, "Panel_hor");
        if (type == 0){
            this.mPlayerNode = Panel_ver;
            Panel_hor.setVisible(false);
        }else{
            this.mPlayerNode = Panel_hor;
            Panel_ver.setVisible(false);
        }
    },

    setJuPlayerInfo : function(juInfo){
        var player = this.mPlayerNode;
        //nick
        mo.gameHelper.setTextString(mo.seekWidgetByName(player, "Text_nick"), mo.gameHelper.getUserNickFilter(juInfo.Nick));

        //uid
        mo.gameHelper.setTextString(mo.seekWidgetByName(player, "Text_id"), "id:" + juInfo.Uid);

        //head
        mo.gameHelper.loadImageForUrl(mo.seekWidgetByName(player, "Image_head"), juInfo.FaceUrl);

        //score
        mo.gameHelper.setTextString(mo.seekWidgetByName(player, "Text_score"), juInfo.Score);

        //输赢
        if (juInfo.Score >= 0){
            mo.gameHelper.loadTextureImage(mo.seekWidgetByName(player, "Image_isWin"), "res/ccs/psz/end/icon_win.png");
        }else{
            mo.gameHelper.loadTextureImage(mo.seekWidgetByName(player, "Image_isWin"), "res/ccs/psz/end/icon_lose.png");
        }

        //通杀
        var Text_tongsha = mo.seekWidgetByName(player, "Text_tongsha");
        var text1 = Text_tongsha.getString().substr(0, Text_tongsha.getString().length - 1);
        mo.gameHelper.setTextString(Text_tongsha, text1 + juInfo.AllWinTimes);

        //通赔
        var Text_tongpei = mo.seekWidgetByName(player, "Text_tongpei");
        var text2 = Text_tongpei.getString().substr(0, Text_tongpei.getString().length - 1);
        mo.gameHelper.setTextString(Text_tongpei, text2 + juInfo.AllLostTimes);

        //牛牛
        var Text_niuniu = mo.seekWidgetByName(player, "Text_niuniu");
        var text3 = Text_niuniu.getString().substr(0, Text_niuniu.getString().length - 1);
        mo.gameHelper.setTextString(Text_niuniu, text3 + juInfo.NNTimes);

        //胜利
        var Text_shengli = mo.seekWidgetByName(player, "Text_shengli");
        var text4 = Text_shengli.getString().substr(0, Text_shengli.getString().length - 1);
        mo.gameHelper.setTextString(Text_shengli, text4 + juInfo.WinTimes);
    },

    setIsFz : function(isFz){
        mo.seekWidgetByName(this.mPlayerNode, "Image_isFz").setVisible(isFz);
    },

    getHonner : function(){
        return mo.seekWidgetByName(this.mPlayerNode, "Panel_honor");
    }
});